package com.trip.wechat.account.service.impl;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.trip.wechat.account.common.dict.RedisKey;
import com.trip.wechat.account.dao.MpMenuDao;
import com.trip.wechat.account.domain.MpAccountPO;
import com.trip.wechat.account.domain.MpMenuPO;
import com.trip.wechat.account.model.AccountBO;
import com.trip.wechat.account.model.MpMenuBO;
import com.trip.wechat.account.service.MpMenuService;
import jdk.nashorn.internal.runtime.JSONFunctions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class MpMenuServiceImpl implements MpMenuService {

    final Logger LOGGER = LoggerFactory.getLogger(this.getClass());

    @Autowired
    MpMenuDao mpMenuDao;


    @Override
    public List<MpMenuBO> getMenus() {
        List<MpMenuBO> menuList = new ArrayList<>();

        mpMenuDao.queryAll()
                .stream()
                .filter(MpMenuPO::getEnabled)
                .forEach(po -> {
                    MpMenuBO bo = new MpMenuBO();
                    BeanUtils.copyProperties(po, bo);
                    menuList.add(bo);
                });

        return menuList;
    }
}
